package org.factory.service.impl;

import lombok.Data;
import org.factory.entity.Computer;
import org.factory.service.Factory;
import org.factory.service.Store;

import java.util.List;

/**
 * @author LiKun
 * @date 2021/8/19 14:48
 */
@Data
public abstract class ComputerStore implements Store, Factory {
    protected List<Computer> computers;

    @Override
    public int sell(int number) {
        int result = number;
        int size = computers.size();
        if (computers.size() < number) {
            result = production(number - size) + size;
        }
        computers.subList(0, result).clear();
        return result;
    }
}
